import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';
import path from 'path';
// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: {
      '@': path.resolve('src') // 设置 `@` 指向 `src` 目录
    }
  },
  server: {
    host: '0.0.0.0',
    port: 666,
    proxy: {
      '/juhe': {
        target: 'http://v.juhe.cn/', // /news/toutiao/index http://v.juhe.cn/toutiao/index
        changeOrigin: true,
        rewrite: path => path.replace(/^\/juhe/, '')
      },
      '/juhe1': {
        target: 'http://apis.juhe.cn/', // /news/toutiao/index http://v.juhe.cn/toutiao/index
        changeOrigin: true,
        rewrite: path => path.replace(/^\/juhe1/, '')
      }
    }
  }
});
